package com.mofeng.myshop.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.mofeng.myshop.domain.po.CommodityCategory;
import com.mofeng.myshop.domain.po.Project;
import com.mofeng.myshop.domain.vo.base.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Builder(toBuilder = true)
public class ProjectVo extends BaseVo {

    @Schema(description = "图片路径")
    private String image;

    @Schema(description = "项目分类，区别调用什么表")
    private String type;

    @Schema(description = "小图标")
    private String iconImage;

    @Schema(description = "是否展示 0 展示 1 不展示 注意，不展示意思是前端将不会显示此分类")
    private String show;

    @Schema(description = "是否打开 0打开 1 关闭  注意，关闭意思是无法访问，但会显示禁止访问提示")
    private String open;

    @Schema(description= "steam直连链接")
    private String link = "";

    List<CommodityCategoryVo> childList = new ArrayList<>();

    List<AddressMapVo> addressList = new ArrayList<>();

    public ProjectVo(Project project) {
        super(project);
        this.image = project.getImage();
        this.type = project.getType();
        this.iconImage = project.getIconImage();
        this.show = project.getShow();
        this.open = project.getOpen();
        this.link = project.getLink();
    }

    public void addChildList(Collection<CommodityCategory> childList) {
        this.childList = CommodityCategoryVo.change(childList);
    }

    public static List<ProjectVo> change(Collection<Project> projects) {
        if (projects == null) {
            return null;
        }
        return projects.stream().map(ProjectVo::new).collect(Collectors.toList());
    }
}
